#!/bin/bash
#开发环境
apt-get purge needrestart -y
apt-get install -y gcc g++ make cmake-curses-gui

# 动态库依赖
#nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.

apt-get install -y  yasm nasm

# ERROR: gnutls not found using pkg-config
apt-get install -y libbluray-dev
# ERROR: gnutls not found using pkg-config
apt install -y libgnutls28-dev

# ERROR: libfdk_aac not found
apt-get install libfdk-aac-dev -y

# ERROR: libmp3lame >= 3.98.3 not found
apt-get install libmp3lame-dev -y

# ERROR: speex not found using pkg-config
apt-get install libspeex-dev -y

# ERROR: libx264 not found
apt-get install libx264-dev -y

# ERROR: x265 not found using pkg-config
apt-get install -y libx265-dev




# 配置动态库位置
#vim /etc/ld.so.conf
#/root/ffmpeg/lib/
# 刷新动态库配置
#ldconfig
#ffmpeg -version


#git clone https://gitee.com/ffbuild/gnutls.git
#   --prefix
#   用以指定编译好的FFmpeg安装到哪个目录
#   一般放到/usr/local/ffmpeg中即可
#   --enable-shared
#   生成动态库
#   --disable-static
#   不生成静态库
#   --enable-libfdk-aac
#   将fdk-aac内置到FFmpeg中
#   --enable-libx264
#   将x264内置到FFmpeg中
#   --enable-libx265
#   将x265内置到FFmpeg中
#   --enable-gpl
#   x264、x265要求开启GPL License
#   --enable-nonfree
#   fdk-aac与GPL不兼容，需要通过开启nonfree进行配置






./configure --prefix=/var/opt/ffmpeg \
	--enable-shared \
	--disable-static \
 	--enable-gpl \
 	--enable-nonfree \
 	--enable-gnutls \
 	--enable-libmp3lame \
    --enable-libfdk-aac \
    --enable-libx264 \
    --enable-libx265 \
    --enable-filter=delogo \
    --enable-debug \
    --enable-optimizations \
    --enable-libspeex \
     --enable-pthreads \
     --enable-version3 \
     --enable-hardcoded-tables \
    --arch=x86_64

echo "/var/opt/ffmpeg/lib" > /etc/ld.so.conf.d/ffmpeg.conf
ldconfig